UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'P4jHbbwO1b3GsCZgaxRQg9v1hkoUZBkMllPxoCmud+A='
WHERE
key_id = 'a18162123500ba9388251427e1954acf40193e295042a75a1c263c47a2cb8cea'
AND (
token = 'P4jHbbwO1b3GsCZgaxRQg9v1hkoUZBkMllPxoCmud+A='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)