UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'ZAVD1349EnhHALt7kVLRYqQKVgJ6X3qiGW7ybFvwrzk='
WHERE
key_id = '666e665c856641e7e25675438f50734eab2741a59aa5f5cb34a5d39aa8f59770'
AND (
token = 'ZAVD1349EnhHALt7kVLRYqQKVgJ6X3qiGW7ybFvwrzk='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)