UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'fjEycp6IiJlJF8ZWI+FsyT9u8rREeJSYE8uY2jr9GYA='
WHERE
key_id = 'f7afed5148641f641c6ba45f77e8ff0e037876e1e864d3336157a0d03103c3d0'
AND (
token = 'fjEycp6IiJlJF8ZWI+FsyT9u8rREeJSYE8uY2jr9GYA='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)